package com.example.demo.mapper;

import com.example.demo.entity.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * @author:王声基
 * @date:2019/12/25
 * @decription:角色数据操作
 */
@Mapper
public interface RoleMapper {

    //插入role表
    @Insert("insert into trole(role_name,description) values(#{roleName},#{description})")
    public int insertRole(String roleName,String description);

    //name模糊查询
    @Select("select tr_id,role_name,description from trole where role_name like #{roleName} ")
    public List<Role> selectRoleByName(String roleName);

    //删除角色
    @Delete("delete from trole where tr_id=#{roleId}")
    public int deleteRole(int roleId);

    //更新角色表
    /*@Update("update trole set rolename=#{rolename},description=#{description} where tr_id=#{roleId}")
    public int updateRoleById(int roleId,String rolename, String description);*/

    //查询某角色的人数
    @Select("SELECT COUNT(*) from tuserrolerelation where Role_id=#{roleId}")
    public int selectCountOfRoleById(int roleId);
}
